from django.db import models
from django.contrib.auth.models import User
from cartoon_us.clan.models import clan
from cartoon_us.gallery.models import ArtWork,WrittenWork,Comic
import decimal



# Create your models here.



class friend(models.Model):
    user=models.CharField(max_length=20)
    of=models.ForeignKey(User)

class my_clans(models.Model):
    clan=models.CharField(max_length=50)
    of=models.ForeignKey(User)
    
class vote(models.Model):
    rate=models.IntegerField()
    count=models.IntegerField()
    on=models.CharField(max_length=50)
    def score(self):
        if self.count == 0:
            return 0
        decimal.getcontext().prec = 2
        return decimal.Decimal(self.rate)/decimal.Decimal(self.count)
    
class comics(models.Model):
    comic=models.ForeignKey(Comic)
    of=models.ForeignKey(User)
    
class illustration(models.Model):
    art=models.ForeignKey(ArtWork)
    of=models.ForeignKey(User)

class story(models.Model):
    work=models.ForeignKey(WrittenWork)
    of=models.ForeignKey(User)

class comment(models.Model):
    title=models.CharField(max_length=50)
    of=models.ForeignKey(User)
    
